package com.ruoyi.sea.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.sea.domain.SeaValue;
import com.ruoyi.sea.service.ISeaValueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 海洋实时统计Controller
 * 
 * @author ruoyi
 * @date 2025-04-07
 */
@RestController
@RequestMapping("/sea/value")
public class SeaValueController extends BaseController
{
    @Autowired
    private ISeaValueService seaValueService;

    /**
     * 查询海洋实时统计列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SeaValue seaValue)
    {
        startPage();
        List<SeaValue> list = seaValueService.selectSeaValueList(seaValue);
        return getDataTable(list);
    }

    /**
     * 导出海洋实时统计列表
     */
    @Log(title = "海洋实时统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SeaValue seaValue)
    {
        List<SeaValue> list = seaValueService.selectSeaValueList(seaValue);
        ExcelUtil<SeaValue> util = new ExcelUtil<SeaValue>(SeaValue.class);
        util.exportExcel(response, list, "海洋实时统计数据");
    }

    /**
     * 获取海洋实时统计详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(seaValueService.selectSeaValueById(id));
    }

    /**
     * 新增海洋实时统计
     */
    @Log(title = "海洋实时统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SeaValue seaValue)
    {
        return toAjax(seaValueService.insertSeaValue(seaValue));
    }

    /**
     * 修改海洋实时统计
     */
    @Log(title = "海洋实时统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SeaValue seaValue)
    {
        return toAjax(seaValueService.updateSeaValue(seaValue));
    }

    /**
     * 删除海洋实时统计
     */
    @Log(title = "海洋实时统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(seaValueService.deleteSeaValueByIds(ids));
    }
}
